package com.hspedu.newData.dmsxl.数组.二分查找;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-22 
 * @Version: 1.0
 */

public class LC367有效的完全平方数 {

    // 一定要注意到不能为0
    public boolean isPerfectSquare(int num) {

        int left = 1;
        int right = num;
        int mid = -1;
        while (left<=right){
            mid = (left+right)>>>1;
            if (num / mid > mid){
                left = mid + 1;
            }else if (num / mid < mid){
                right = mid - 1;
            }else {
                break;
            }
        }
        return mid*mid == num;
    }

    @Test
    public void test(){
        boolean perfectSquare = isPerfectSquare(14);
        System.out.println("=========");
    }
}
